<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('Admin/Prop/add', array('live_id'=>$live_id))}">添加{$title}</a></li>
		</ul>
		<div style="padding: 10px;">
			<span style="padding-right: 200px; font-size: 16px; font-weight: bold;">打赏类型：{$title}</span>
			<span style="padding-right: 200px; font-size: 16px; font-weight: bold;">直播间总PK人气值：<if condition="$prop_info.popular neq ''">{$prop_info.popular}<else/>0</if></span>
			<span style="padding-right: 200px; font-size: 16px; font-weight: bold;">直播总参与人数：<a href='{:U("Admin/LiveCompetitor/prop_info",array("live_id"=>$live_id))}'>{$prop_info.total}</a></span>
			</div>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th>序号</th>
					<th>创建时间</th>
					<th>pk标题</th>
					<th>对阵双方</th>
					<th>对阵选手</th>
					<th>PK人气值</th>
					<th>参与人数</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="pk_info" item="vo" key="keys">
					<?php
					foreach($vo['competitor'] as $key=>$val){
					?>
					<if condition="$key eq 0">
						<td rowspan="<?php if(count($vo['competitor'])) echo count($vo['competitor']);?>">{$keys+1}</td>
						<td rowspan="<?php if(count($vo['competitor'])) echo count($vo['competitor']);?>">{$vo.create_time}</td>
						<td rowspan="<?php if(count($vo['competitor'])) echo count($vo['competitor']);?>"><input type="text" value="{$vo.title}" disabled name="title" class="title" id="title_{$vo.id}">&nbsp;&nbsp;<input type="button" name="edit" id="edit_{$vo.id}" value="修改" class="edit" onclick="editTitle('{$vo.id}');"></td>
					</if>
					<td><if condition="$val.group_id eq 1"><span style="color: red;">红方</span><else/><span style="color: #00a0e9">蓝方</span></if></td>
					<td>{$val.competitor_name}</td>
					<td><if condition="$val.popular neq ''">{$val.popular}<else/>0</if></td>
					<td><a href='{:U("Admin/LiveCompetitor/prop_info",array("competitor_id"=>$val["competitor_id"], "live_id"=>$live_id, "pk_id"=>$vo["id"]))}'>{$val.num}</a></td>
					<if condition="$key eq 0">
						<td rowspan="<?php if(count($vo['competitor'])) echo count($vo['competitor']);?>">
							<if condition="$vo.status eq 1">
								<a href='#' onclick="change_status('{$vo.id}', '2')">禁用</a>
								<elseif condition="$vo.status eq 2"/>
								<a href='#' onclick="change_status('{$vo.id}', '1')">启用</a>
							</if>
							<a href='{:U("Admin/Prop/edit_status", array("pk_id"=>$vo["id"], "status"=>3))}' class="js-ajax-delete" data-msg="确定要删除此地区吗？">删除</a>
						</td>
					</if>
				</tr>
					<?php
					}
					?>
				</foreach>
			</tbody>
		</table>
		</form>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js"></script>
	<script src="__PUBLIC__/js/layer/layer.js"></script>
	<script>
	function editTitle(id){
		var edit_button = $("#edit_"+id).val();
		if(edit_button == "修改"){
			$(".title").attr("disabled", "disabled");
			$(".edit").val("修改");
			$("#title_"+id).removeAttr("disabled");
			$("#edit_"+id).val("确认");
		}else{
			var title = $("#title_"+id).val();
			$.ajax({
				type: "POST",
				cache: false,
				data: "pk_id="+id+"&title="+title,
				async: false,
				url: "{:U('Prop/editTitle')}",
				success: function(ret) {
					if(ret['code'] == 200){
						$("#title_"+id).attr("disabled", "disabled");
						$("#edit_"+id).val("修改");
						location.reload()
					}else{
						alert(ret.msg)
					}
				}, error: function(data) {
					alert('网络错误，请稍后再试！');
				}
			});
		}
	}

	function change_status(id,status) {
		$.post("{:U('Prop/edit_status')}",{pk_id:id,status:status},function(result) {
			if (result == '1') {
				alert('设置成功');
				location.reload();
			} else {
				var msg = '设置失败';
				alert(msg);
			}
		})
	}
	</script>
</body>
</html>